package com.violet.detective.controller;

import com.violet.detective.entity.FileModel;
import com.violet.detective.service.DefectService;
import com.violet.detective.service.EquipmentService;
import com.violet.detective.service.WorkorderService;
import com.violet.detective.util.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.sql.rowset.serial.SerialBlob;
import java.io.IOException;
import java.sql.Blob;
import java.sql.SQLException;

@RestController
@RequestMapping("/file")
public class FileController {
    @Resource
    EquipmentService equipmentService;
    @Resource
    DefectService defectService;
    @Resource
    WorkorderService workorderService;

    @PostMapping("/upload")
    public R uploadFile(@RequestParam("file") MultipartFile file, @RequestParam String comp, @RequestParam Integer compId) {
        Blob blob;
        try {
            blob = new SerialBlob(file.getBytes());
        } catch (SQLException | IOException e) {
            return R.error(e.getMessage());
        }

        FileModel fileModel = new FileModel();

        return null;
    }
}
